package classes.Commands
{
	import components.editor.c_baseElement;
	
	public class c_visibilityCommand extends c_baseCommand {
		protected var _prevLink	: c_baseElement;		
		private var _visible	: Boolean;
		public function c_visibilityCommand(a_element: c_baseElement, a_visible: Boolean) {
			super(a_element);
			_visible = a_visible;
		}
		
		override public function Execute():void {
			_prevLink = editor.dragRect.link;
			element.visible = _visible;
			if ((editor.dragRect.link == element) && !element.visible) {
				editor.dragRect.link = null;
			} else if (element.visible) editor.dragRect.link = element as c_baseElement;
		}
		
		override public function unExecute():void {
			element.visible = !_visible;
			editor.dragRect.link = _prevLink;
		}
	}
}